{% assign data = section.settings %}

{% if section.settings.is_width_fill %}
  {% assign container = 'container_fill' %}
{% else %}
  {% assign container = 'container_wrapper' %}
{% endif %}

<div
  class="block_image_text"
  style="--bg: {{data.bg_color}};--padding: {{data.padding.top}}px {{data.padding.right}}px {{data.padding.bottom}}px {{data.padding.left}}px;"
>
  <div class="{{container}}">
    <div class="content flex md:flex-row flex-col overflow-hidden">
      <div class="img_box flex-1 flex items-center">
        {% include 'lazy_img', src: data.image.src, alt: data.image.alt, class: 'w-full h-full object-cover' %}
      </div>
      <div class="text_box flex-1 flex items-center" style="--text-color: {{data.text_color}}">
        <div class="text_content box-border md:p-24">
          {% if data.subtitle != '' %}
            <div class="text_subtitle public_subtitle mb-5">{{ data.subtitle }}</div>
          {% endif %}
          {% if data.title != '' %}
            <div class="text_title public_title">{{ data.title }}</div>
          {% endif %}
          {% if data.detail != '' %}
            <div class="text_detail mt-5">{{ data.detail }}</div>
          {% endif %}
          {% if data.btn_text != '' %}
            <div class="btn_wrap mt-5" style="--btn-color: {{data.btn_color}};--btn-bg: {{data.btn_bg}};">
              {% include 'btn', link: data.link, btn_text: data.btn_text %}
            </div>
          {% endif %}
        </div>
      </div>
    </div>
  </div>
</div>

{% schema %}
{
  "class": "block_image_text",
  "is_global": false,
  "icon": "icon-tuwen",
  "name": {
    "zh_CN": "图文",
    "en_US": "Image and text"
  },
  "blocks": [],
  "settings": [
    {
      "type": "card_header",
      "label": {
        "zh_CN": "设置",
        "en_US": "Settings"
      }
    },
    {
      "type": "card_layout",
      "label": {
        "zh_CN": "内容留白",
        "en_US": "Content blank"
      },
      "id": "padding",
      "default": {
        "top": "0",
        "left": "0",
        "right": "0",
        "bottom": "0"
      }
    },
    {
			"type": "card_switch",
			"label": {
				"zh_CN": "宽度铺满",
				"en_US": "Spread the width"
			},
			"id": "is_width_fill",
			"default": true
		},
    {
      "type": "card_image",
      "label": {
        "zh_CN": "图片",
        "en_US": "Image"
      },
      "default": {
        "src": "",
        "alt": ""
      },
      "info": {
        "zh_CN": "建议宽度1000px以上，高度自适应",
        "en_US": "Recommended width more than 1000px, height adaptive"
      },
      "id": "image"
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "副标题",
        "en_US": "Subtitle"
      },
      "default": "",
      "id": "subtitle"
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "标题",
        "en_US": "Title"
      },
      "default": "Media with text",
      "id": "title"
    },
    {
      "type": "card_text_editor",
      "label": {
        "zh_CN": "简短描述",
        "en_US": "Short description"
      },
      "id": "detail",
      "default": "Pair text with media to give customers insight into your brand. Tell a story, explain a product detail, or describe a new promotion."
    },
    {
      "type": "card_input",
      "label": {
        "zh_CN": "按钮文字",
        "en_US": "Button text"
      },
      "default": "Read more",
      "id": "btn_text"
    },
    {
      "type": "card_page_link",
      "label": {
        "zh_CN": "按钮链接",
        "en_US": "Button link"
      },
      "default": {
        "type": "",
        "title": "",
        "url": ""
      },
      "id": "link"
    },
    {
      "type": "card_header",
      "label": {
        "zh_CN": "颜色设置",
        "en_US": "Color Settings"
      }
    },
    {
      "type": "card_color",
      "id": "bg_color",
      "label": {
        "zh_CN": "背景颜色",
        "en_US": "Background color"
      },
      "default": "#e0e0e0"
    },
    {
      "type": "card_color",
      "id": "text_color",
      "label": {
        "zh_CN": "文字颜色",
        "en_US": "Text color"
      },
      "default": "#000000"
    },
    {
      "type": "card_color",
      "id": "btn_color",
      "label": {
        "zh_CN": "按钮文字颜色",
        "en_US": "Button text color"
      },
      "default": "#ffffff"
    },
    {
      "type": "card_color",
      "id": "btn_bg",
      "label": {
        "zh_CN": "按钮背景颜色",
        "en_US": "Button background color"
      },
      "show-alpha": "false",
      "color-format": "rgb",
      "default": "rgba(223,86,65,1)"
    }
  ],
  "default": {
    "settings": {
      "is_width_fill": false,
      "padding": {
        "top": "0",
        "left": "0",
        "right": "0",
        "bottom": "0"
      },
      "image": {
        "src": "",
        "alt": ""
      },
      "subtitle": "",
      "title": "Media with text",
      "detail": "Pair text with media to give customers insight into your brand. Tell a story, explain a product detail, or describe a new promotion.",
      "btn_text": "Read more",
      "link": {
        "type": "",
        "title": "",
        "url": ""
      },
      "bg_color": "#e0e0e0",
      "text_color": "#1D1F21",
      "btn_color": "#ffffff",
      "btn_bg": "rgba(223,86,65,1)"
    },
    "blocks": []
  }
}
{% endschema %}
